package net.oschina.app.base;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import net.oschina.app.factory.BaseFactory;

/**
 * Created by wei03 on 2017/1/13.
 */

public class BasePagerAdapter extends FragmentStatePagerAdapter {
    private String[] mFragmentTitles;
    private BaseFactory mFactory;

    public BasePagerAdapter(FragmentManager fm, String[] fragmentTitles, Object factory) {
        super(fm);
        mFragmentTitles = fragmentTitles;
        mFactory = (BaseFactory) factory;
    }

    @Override
    public Fragment getItem(int position) {
        return mFactory.getFragment(position);
    }

    @Override
    public int getCount() {
        return mFragmentTitles.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mFragmentTitles[position];
    }
}
